import { IPSSysBICubeDimension } from './ipssys-bicube-dimension';
import { IPSSysBICubeLevel } from './ipssys-bicube-level';
import { IPSSysBIHierarchy } from './ipssys-bihierarchy';
import { IPSSysBILevel } from './ipssys-bilevel';
import { PSSysBICubeDimensionObjectImpl } from './pssys-bicube-dimension-object-impl';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEField } from '../dataentity/defield/ipsdefield';

export class PSSysBICubeLevelImpl extends PSSysBICubeDimensionObjectImpl implements IPSSysBICubeLevel {
  get codeName(): string {
    return this.M.codeName;
  }

  get levelTag(): string {
    return this.M.levelTag;
  }

  get levelTag2(): string {
    return this.M.levelTag2;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdefield = ipsdataentity.findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  protected pssysbihierarchy: IPSSysBIHierarchy | null = null;

  getPSSysBIHierarchy(): IPSSysBIHierarchy | null {
    if (this.pssysbihierarchy != null) return this.pssysbihierarchy;
    const value = this.M.getPSSysBIHierarchy;
    if (value == null) {
      return null;
    }
    const ipssysbicubedimension = this.getParentPSModelObject('bi.IPSSysBICubeDimension') as IPSSysBICubeDimension;
    if (ipssysbicubedimension != null) {
      this.pssysbihierarchy = ipssysbicubedimension.getPSSysBIDimensionMust().findPSSysBIHierarchy(value);
    }
    return this.pssysbihierarchy;
  }

  get psSysBIHierarchy(): IPSSysBIHierarchy | null {
    return this.getPSSysBIHierarchy();
  }

  getPSSysBIHierarchyMust(): IPSSysBIHierarchy {
    const value = this.getPSSysBIHierarchy();
    if (value == null) {
      throw new Error('未指定智能报表维度架构');
    }
    return value;
  }

  protected pssysbilevel: IPSSysBILevel | null = null;

  getPSSysBILevel(): IPSSysBILevel | null {
    if (this.pssysbilevel != null) return this.pssysbilevel;
    const value = this.M.getPSSysBILevel;
    if (value == null) {
      return null;
    }
    const ipssysbihierarchy = this.getPSSysBIHierarchy();
    if (ipssysbihierarchy != null) {
      this.pssysbilevel = ipssysbihierarchy.findPSSysBILevel(value);
    }
    return this.pssysbilevel;
  }

  get psSysBILevel(): IPSSysBILevel | null {
    return this.getPSSysBILevel();
  }

  getPSSysBILevelMust(): IPSSysBILevel {
    const value = this.getPSSysBILevel();
    if (value == null) {
      throw new Error('未指定智能报表维度层级');
    }
    return value;
  }

  get cls(): string {
    return 'PSSysBICubeLevelImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'bi.IPSBICubeLevel' || cls == 'bi.IPSSysBICubeLevel') return true;
    return super.instanceof(cls);
  }
}
